// 随机图片服务
const getRandomImage = (width, height, category = '') => {
  const baseUrl = 'https://images.unsplash.com'
  const categories = {
    drama: [
      'photo-1529626455594-4ff0802cfb7e',
      'photo-1535713875002-d1d0cf377fde',
      'photo-1507003211169-0a1dd7228f2d',
      'photo-1438761681033-6461ffad8d80',
      'photo-1508214751196-bcfd4ca60f91',
      'photo-1518676590629-3dcbd9c5a5c9',
      'photo-1544725176-7c40e5a71c5e',
      'photo-1573496359142-b8d87734a5a2',
      'photo-1507003211169-0a1dd7228f2d',
      'photo-1536440136628-849c177e76a1'
    ],
    avatar: [
      'photo-1535713875002-d1d0cf377fde',
      'photo-1507003211169-0a1dd7228f2d',
      'photo-1438761681033-6461ffad8d80',
      'photo-1508214751196-bcfd4ca60f91'
    ]
  }

  const imageIds = categories[category] || categories.drama
  const randomId = imageIds[Math.floor(Math.random() * imageIds.length)]

  return `${baseUrl}/${randomId}?w=${width}&h=${height}&fit=crop`
}

// 统一的视频数据结构
export const generateVideoData = () => {
  return {
    msg: '成功',
    code: 200,
    'data|20': [
      {
        // 基本信息
        'id|+1': 1,
        title: '@ctitle(5, 15)',
        description: '@cparagraph(1, 3)',
        cover: () => getRandomImage(150, 200, 'drama'),
        videoUrl:
          'https://videocdn.cdnpk.net/videos/c80fe480-9cdc-5c50-8d25-6716f7a0f46f/vertical/previews/clear/small.mp4?token=exp=1755796576~hmac=12ef82f9339e7952a824f2fe0bef423336752f051f62eaa29b60b3c6b4e3d86d',

        // 剧集信息
        'totalEpisodes|12-100': 24,
        'currentEpisode|1-24': 1,
        episodeTitle: '第' + '@integer(1, 24)' + '集',
        progress: () => Math.floor(Math.random() * 100) + 1,

        // 统计数据
        'playCount|1000-10000000': 1000,
        'likeCount|100-100000': 100,
        'starCount|50-50000': 50,
        'commentCount|10-10000': 10,

        // 用户交互状态
        'isLiked|1': [true, false],
        'isStarred|1': [true, false],
        'isFollowing|1': [true, false],
        'isWatched|1': [true, false],

        // 创作者信息
        author: '@cname',
        authorId: '@id',
        authorAvatar: () => getRandomImage(50, 50, 'avatar'),

        // 分类标签
        'category|1': ['古装', '现代', '玄幻', '都市', '言情', '悬疑', '科幻', '历史'],
        'tags|2-5': ['@cword(2, 4)'],

        // 音乐信息
        music: '@cword(3, 8)',
        musicAuthor: '@cname',

        // 时间信息
        publishTime: '@datetime("yyyy-MM-dd HH:mm:ss")',
        updateTime: '@datetime("yyyy-MM-dd HH:mm:ss")',

        // 评分信息
        'rating|3.5-5.0': 5.0,
        'ratingCount|100-10000': 100,

        // 状态信息
        'status|1': ['连载中', '已完结', '即将上映'],
        'quality|1': ['720P', '1080P', '4K'],

        // 评论数据
        'comments|5-20': [
          {
            'id|+1': 1,
            userName: '@cname',
            userAvatar: () => getRandomImage(40, 40, 'avatar'),
            content: '@cparagraph(1, 2)',
            'likeCount|0-100': 0,
            time: '@datetime("yyyy-MM-dd HH:mm:ss")',
            'isLiked|1': [true, false]
          }
        ],

        // 集数列表
        'episodes|12-100': [
          {
            'id|+1': 1,
            title: '第' + '@integer(1, 100)' + '集 ' + '@cword(3, 10)',
            'duration|1800-3600': 1800,
            playUrl:
              'https://videocdn.cdnpk.net/videos/c80fe480-9cdc-5c50-8d25-6716f7a0f46f/vertical/previews/clear/small.mp4?token=exp=1755796576~hmac=12ef82f9339e7952a824f2fe0bef423336752f051f62eaa29b60b3c6b4e3d86d',
            'isWatched|1': [true, false],
            publishTime: '@datetime("yyyy-MM-dd")'
          }
        ],

        // 推荐相关
        'relatedVideos|4-8': [
          {
            'id|+1': 100,
            title: '@ctitle(5, 12)',
            cover: () => getRandomImage(120, 160, 'drama'),
            'playCount|1000-100000': 1000,
            'rating|3.5-5.0': 5.0
          }
        ]
      }
    ]
  }
}

export default generateVideoData()
